import request from '@/tools/request'

/**
 * 获取用户的流程
 * @param id
 * @returns {AxiosPromise}
 */
export function getTasksById(id) {
    return request({
        url: 'workflow/getTasksById',
        method: 'get',
        params: {
            userId: id
        }
    })
}

/**
 * 获取流程表单
 * @param id
 * @returns {AxiosPromise}
 */
export function getTaskForm(id) {
    return request({
        url: 'workflow/getTaskForm',
        method: 'get',
        params: {
            instanceId: id
        }
    })
}

/**
 * 获取部署列表
 * @returns {AxiosPromise}
 */
export function getDeployList() {
    return request({
        url: 'workflow/getDeployList',
        method: 'get',
    })
}

/**
 * 启动流程
 * @param id
 * @returns {AxiosPromise}
 */
export function start(id, userid) {
    return request({
        url: 'workflow/start',
        method: 'get',
        params: {
            userId: userid,
            deploymentId: id
        }
    })
}

/**
 * 提交表单
 * @param instanceId
 * @param data
 * @returns {AxiosPromise}
 */
export function submitTask(instanceId, userid, data) {
    return request({
        url: 'workflow/comTask',
        method: 'post',
        params: {
            userId: userid,
            instanceId: instanceId
        },
        data: data
    })
}

/**
 * 获取表单数据
 * @param instanceId
 * @returns {AxiosPromise}
 */
export function getFormData(instanceId) {
    return request({
        url: 'workflow/getStartFormData',
        method: 'get',
        params: {
            instanceId: instanceId
        },
    })
}